/*
 * MyButton.fx
 *
 * Created on 5-mag-2011, 13.34.28
 */

package jfx_mobile_test_01;

/**
 * @author Mitch
 */


import javafx.scene.*;
import javafx.scene.text.*;
import javafx.scene.image.*;
import javafx.scene.layout.*;
import javafx.scene.shape.*;
import javafx.scene.paint.*;
import javafx.scene.layout.*;


public class MyButton extends CustomNode {

    public var ButtonX: Number;
    public var ButtonY: Number;
    public var ButtonText: String;
    public var ButtonIcon: String;

    var myButton: Panel;

    var image: Image;
    var btn_icon: ImageView;
    var btn_text: Text;
    var btn_hbox: HBox;
    var btn_rectangle: Rectangle;
    var ButtonBkgnColor: Color;
    var ButtonBorderColor: Color;
   

    public override function create(): Node  {

        btn_text = Text {
            layoutX: 0.0
            layoutY: 0.0
            content: ButtonText
        };
        image = Image {
            url: ButtonIcon  //"{__DIR__}icon.jpg"
        };
        btn_icon = ImageView {
            layoutInfo: LayoutInfo {
                width: 0.0
                height: 0.0
            }
            image: image
            fitWidth: 16.0
            fitHeight: 16.0
        };
        btn_hbox = HBox {
            opacity: 1.0
            layoutX: 5.0
            layoutY: 2.0
            content: [ btn_icon, btn_text, ]
            spacing: 6.0
        };
        ButtonBkgnColor = Color {
            red: 0.0
            green: 0.0
            blue: 0.0
            opacity: 0.0
        };
        ButtonBorderColor = Color {
            red: 0.0
            green: 0.0
            blue: 0.0
        };
        btn_rectangle = Rectangle {
            opacity: 0.49
            fill: ButtonBkgnColor
            stroke: ButtonBorderColor
            strokeWidth: 2.0
            width: 100.0
            height: 20.0
        };
        myButton = Panel {
            layoutX: ButtonX //68.0
            layoutY: ButtonY //53.0
            width: btn_rectangle.height
            height: btn_rectangle.width
            layoutInfo: LayoutInfo {
                width: bind myButton.width
                height: bind myButton.height
            }
            content: [ btn_hbox, btn_rectangle, ]
        };

    }

}
